package org.boyan.modules.cgform.enhance.a;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.boyan.common.system.api.ISysBaseAPI;
import org.boyan.common.system.vo.SysCategoryModel;
import org.boyan.common.util.oConvertUtils;
import org.boyan.modules.cgform.enhance.CgformEnhanceJavaListInter;
import org.boyan.modules.cgform.entity.OnlCgformField;
import org.boyan.modules.cgform.service.IOnlCgformFieldService;
import org.boyan.modules.config.exception.BusinessException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component("cgformEnhanceExportDemo")
public class b implements CgformEnhanceJavaListInter {
    @Autowired
    ISysBaseAPI sysBaseAPI;

    @Autowired
    IOnlCgformFieldService onlCgformFieldService;

    @Override
    public void execute(String tableName, List<Map<String, Object>> data) throws BusinessException {
        List<SysCategoryModel> list = this.sysBaseAPI.queryAllDSysCategory();
        for (Map<String, Object> map : data) {
            String str1 = oConvertUtils.getString(map.get("fen_tree"));
            if (oConvertUtils.isEmpty(str1)) {
                continue;
            }
            List<SysCategoryModel> list1 = (List)list.stream().filter(paramSysCategoryModel ->
                    paramSysCategoryModel.getId().equals(str1)).collect(Collectors.toList());
            if (list1.size() != 0) {
                map.put("fen_tree", list1.get(0).getName());
            }
            String str2 = oConvertUtils.getString(map.get("sel_search"));
            if (oConvertUtils.isEmpty(str2)) {
                continue;
            }
            OnlCgformField onlCgformField = this.onlCgformFieldService.queryFormFieldByTableNameAndField(tableName, "sel_search");
            if (onlCgformField == null || oConvertUtils.isEmpty(onlCgformField.getDictTable())) {
                continue;
            }
            List<String> list2 = this.sysBaseAPI.queryTableDictByKeys(onlCgformField.getDictTable(), onlCgformField.getDictText(), onlCgformField.getDictField(), new String[] { str2 });
            if (list2 != null && list2.size() > 0) {
                map.put("sel_search", list2.get(0));
            }
        }
    }
}
